// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   SalaryField.java

package com.oa.hr;

import com.oa.database.DataConn;
import com.oa.database.QueryData;
import com.oa.util.Format;
import java.io.PrintStream;
import java.sql.*;
import java.util.ArrayList;
import java.util.Collection;

// Referenced classes of package com.oa.hr:
//            SalaryFieldInfor

public class SalaryField
{

    private DataConn dataConn;
    private QueryData queryData;
    private Format format;
    private ResultSet rs;
    private SalaryFieldInfor salaryFieldInfor;
    private ArrayList salaryFieldList;
    private String sTable;
    private String sField;
    private String sCond;
    private String sql;

    public SalaryField()
    {
        dataConn = null;
        queryData = null;
        format = null;
        rs = null;
        salaryFieldInfor = null;
        salaryFieldList = new ArrayList();
        sTable = "";
        sField = "";
        sCond = "";
        sql = "";
    }

    public SalaryField(DataConn dataConnection)
    {
        dataConn = null;
        queryData = null;
        format = null;
        rs = null;
        salaryFieldInfor = null;
        salaryFieldList = new ArrayList();
        sTable = "";
        sField = "";
        sCond = "";
        sql = "";
        dataConn = dataConnection;
        queryData = new QueryData(dataConn);
    }

    public ArrayList getSalaryFieldList()
    {
        return salaryFieldList;
    }

    public SalaryFieldInfor getSalaryFieldInfor(int id)
        throws SQLException
    {
        try
        {
            sTable = "OA_YG_GZZD";
            sField = "OA_YG_GZZDID,ZDSM,ZDMC,ZDLX,ZDZJ,ZDLB,ZDFL,ZDSX,ZDMR,ZDBZ,ZDKS";
            sCond = "OA_YG_GZZDID=" + id;
            queryData.setMultRecordSet(sTable, sField, sCond);
            rs = queryData.getResultSet();
            if(rs.next())
            {
                salaryFieldInfor = new SalaryFieldInfor();
                salaryFieldInfor.setId(rs.getInt("OA_YG_GZZDID"));
                salaryFieldInfor.setDesc(rs.getString("ZDSM"));
                salaryFieldInfor.setName(rs.getString("ZDMC"));
                salaryFieldInfor.setType(rs.getString("ZDLX"));
                salaryFieldInfor.setIsAdd(rs.getInt("ZDZJ"));
                salaryFieldInfor.setList(rs.getInt("ZDLB"));
                salaryFieldInfor.setWelfare(rs.getInt("ZDFL"));
                salaryFieldInfor.setOrder(rs.getInt("ZDSX"));
                salaryFieldInfor.setDefValue(rs.getFloat("ZDMR"));
                salaryFieldInfor.setRemark(rs.getString("ZDBZ"));
                salaryFieldInfor.setCanDelete(rs.getInt("ZDKS"));
            }
            rs.close();
        }
        catch(SQLException e)
        {
            System.out.println(e.getMessage());
            throw e;
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }
        return salaryFieldInfor;
    }

    public Collection getList(String sCondition)
        throws SQLException
    {
        try
        {
            sTable = "OA_YG_GZZD";
            sField = "OA_YG_GZZDID,ZDSM,ZDMC,ZDLX,ZDZJ,ZDLB,ZDFL,ZDSX,ZDMR,ZDBZ,ZDKS";
            sCond = sCondition;
            queryData.setMultRecordSet(sTable, sField, sCond);
            for(rs = queryData.getResultSet(); rs.next(); salaryFieldList.add(salaryFieldInfor))
            {
                salaryFieldInfor = new SalaryFieldInfor();
                salaryFieldInfor.setId(rs.getInt("OA_YG_GZZDID"));
                salaryFieldInfor.setDesc(rs.getString("ZDSM"));
                salaryFieldInfor.setName(rs.getString("ZDMC"));
                salaryFieldInfor.setType(rs.getString("ZDLX"));
                salaryFieldInfor.setIsAdd(rs.getInt("ZDZJ"));
                salaryFieldInfor.setList(rs.getInt("ZDLB"));
                salaryFieldInfor.setWelfare(rs.getInt("ZDFL"));
                salaryFieldInfor.setOrder(rs.getInt("ZDSX"));
                salaryFieldInfor.setDefValue(rs.getFloat("ZDMR"));
                salaryFieldInfor.setRemark(rs.getString("ZDBZ"));
                salaryFieldInfor.setCanDelete(rs.getInt("ZDKS"));
            }

            rs.close();
        }
        catch(SQLException e)
        {
            System.out.println(e.getMessage());
            throw e;
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }
        return salaryFieldList;
    }

    public int getMaxOrder()
    {
        int max = 1;
        try
        {
            sql = "select Max(ZDSX) as num from OA_YG_GZZD";
            Statement stmt = dataConn.getConnection().createStatement();
            rs = stmt.executeQuery(sql);
            if(rs.next())
                max = rs.getInt("num") + 1;
            stmt.close();
        }
        catch(Exception exception) { }
        return max;
    }

    public static void main(String args[])
    {
        SalaryField salaryField1 = new SalaryField();
    }
}
